package com.example.server.service;

import com.example.server.domain.BuildingStudents;
import com.example.server.domain.Dorms;
import com.example.server.mapper.BuildingStudentsMapper;
import com.example.server.mapper.DormsMapper;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;
import java.util.UUID;

//所有的业务逻辑方法都放在这个类里
//CRUD--create, read, update, delete
@Service
public class DormsService {

    private final DormsMapper dormsMapper;

    private final BuildingStudentsMapper buildingStudentsMapper;

    public DormsService(DormsMapper dormsMapper,BuildingStudentsMapper buildingStudentsMapper) {
        this.dormsMapper = dormsMapper;
        this.buildingStudentsMapper = buildingStudentsMapper;
    }

    public Dorms getDormById(Long id) {
        return dormsMapper.selectByPrimaryKey(id);
    }
    public List<Dorms> getAllDorms() {
        return dormsMapper.selectAll();
    }
    public void createDorm(Dorms dorms) {
        dormsMapper.insert(dorms);
    }
    public void updateDorm(Dorms dorms) {
        dormsMapper.updateByPrimaryKey(dorms);
    }
    public void deleteDorm(Long id) {
        dormsMapper.deleteByPrimaryKey(id);
    }




    public Dorms queryByRoom(String room) {
        Dorms dorms = new Dorms();
        dorms.setRoom(room);

        return dormsMapper.selectOne(dorms);
    }

    public List<BuildingStudents> summary() {

        return buildingStudentsMapper.selectAll();
    }
}
